﻿using System.Collections;
using System.Configuration;
using System.Text;
using MPMovieCatalog.Util;

namespace MPMovieCatalog.Configuration.Sections
{
    public sealed class HTMLExportSection : PropertySection
    {
        [ConfigurationProperty("movies")]
        private PropertyElement m_movies
        {
            get
            {
                PropertyElement movies = (PropertyElement)base["movies"];
                return movies;
            }

            set
            {
                base["movies"] = value;
            }
        }

        [ConfigurationProperty("listType")]
        private PropertyElement m_listType
        {
            get
            {
                PropertyElement listType = (PropertyElement)base["listType"];
                return listType;
            }

            set
            {
                base["listType"] = value;
            }
        }

        [ConfigurationProperty("itemsPerPage")]
        private PropertyElement m_itemsPerPage
        {
            get
            {
                PropertyElement itemsPerPage = (PropertyElement)base["itemsPerPage"];
                return itemsPerPage;
            }

            set
            {
                base["itemsPerPage"] = value;
            }
        }

        [ConfigurationProperty("folder")]
        private PropertyElement m_folder
        {
            get
            {
                PropertyElement folder = (PropertyElement)base["folder"];
                return folder;
            }

            set
            {
                base["folder"] = value;
            }
        }

        [ConfigurationProperty("indexFileName")]
        private PropertyElement m_indexFileName
        {
            get
            {
                PropertyElement indexFileName = (PropertyElement)base["indexFileName"];
                return indexFileName;
            }

            set
            {
                base["indexFileName"] = value;
            }
        }

        [ConfigurationProperty("overwriteFiles")]
        private PropertyElement m_overwriteFiles
        {
            get
            {
                PropertyElement overwriteFiles = (PropertyElement)base["overwriteFiles"];
                return overwriteFiles;
            }

            set
            {
                base["overwriteFiles"] = value;
            }
        }


        [ConfigurationProperty("openIndexPage")]
        private PropertyElement m_openIndexPage
        {
            get
            {
                PropertyElement openIndexPage = (PropertyElement)base["openIndexPage"];
                return openIndexPage;
            }

            set
            {
                base["openIndexPage"] = value;
            }
        }

        [ConfigurationProperty("indexTitle")]
        private PropertyElement m_indexTitle
        {
            get
            {
                PropertyElement indexTitle = (PropertyElement)base["indexTitle"];
                return indexTitle;
            }

            set
            {
                base["indexTitle"] = value;
            }
        }

        [ConfigurationProperty("indexType")]
        private PropertyElement m_indexType
        {
            get
            {
                PropertyElement indexType = (PropertyElement)base["indexType"];
                return indexType;
            }

            set
            {
                base["indexType"] = value;
            }
        }

        [ConfigurationProperty("fontName")]
        private PropertyElement m_fontName
        {
            get
            {
                PropertyElement fontName = (PropertyElement)base["fontName"];
                return fontName;
            }

            set
            {
                base["fontName"] = value;
            }
        }

        [ConfigurationProperty("fontSize")]
        private PropertyElement m_fontSize
        {
            get
            {
                PropertyElement fontSize = (PropertyElement)base["fontSize"];
                return fontSize;
            }

            set
            {
                base["fontSize"] = value;
            }
        }

        [ConfigurationProperty("fontColor")]
        private PropertyElement m_fontColor
        {
            get
            {
                PropertyElement fontColor = (PropertyElement)base["fontColor"];
                return fontColor;
            }

            set
            {
                base["fontColor"] = value;
            }
        }

        [ConfigurationProperty("backColor")]
        private PropertyElement m_backColor
        {
            get
            {
                PropertyElement backColor = (PropertyElement)base["backColor"];
                return backColor;
            }

            set
            {
                base["backColor"] = value;
            }
        }

        [ConfigurationProperty("thumbSize")]
        private PropertyElement m_thumbSize
        {
            get
            {
                PropertyElement thumbSize = (PropertyElement)base["thumbSize"];
                return thumbSize;
            }

            set
            {
                base["thumbSize"] = value;
            }
        }

        [ConfigurationProperty("includeCreationDate")]
        private PropertyElement m_includeCreationDate
        {
            get
            {
                PropertyElement includeCreationDate = (PropertyElement)base["includeCreationDate"];
                return includeCreationDate;
            }

            set
            {
                base["includeCreationDate"] = value;
            }
        }

        [ConfigurationProperty("customLayoutType")]
        private PropertyElement m_customLayoutType
        {
            get
            {
                PropertyElement customLayoutType = (PropertyElement)base["customLayoutType"];
                return customLayoutType;
            }

            set
            {
                base["customLayoutType"] = value;
            }
        }

        [ConfigurationProperty("shadingEnabled")]
        private PropertyElement m_shadingEnabled
        {
            get
            {
                PropertyElement shadingEnabled = (PropertyElement)base["shadingEnabled"];
                return shadingEnabled;
            }

            set
            {
                base["shadingEnabled"] = value;
            }
        }

        [ConfigurationProperty("showThumb")]
        private PropertyElement m_showThumb
        {
            get
            {
                PropertyElement showThumb = (PropertyElement)base["showThumb"];
                return showThumb;
            }

            set
            {
                base["showThumb"] = value;
            }
        }

        [ConfigurationProperty("fields")]
        private PropertyElement m_fields
        {
            get
            {
                PropertyElement fields = (PropertyElement)base["fields"];
                return fields;
            }

            set
            {
                base["fields"] = value;
            }
        }

        [ConfigurationProperty("columnsCount")]
        private PropertyElement m_columnsCount
        {
            get
            {
                PropertyElement columnsCount = (PropertyElement)base["columnsCount"];
                return columnsCount;
            }

            set
            {
                base["columnsCount"] = value;
            }
        }

        [ConfigurationProperty("thumbBackColor")]
        private PropertyElement m_thumbBackColor
        {
            get
            {
                PropertyElement thumbBackColor = (PropertyElement)base["thumbBackColor"];
                return thumbBackColor;
            }

            set
            {
                base["thumbBackColor"] = value;
            }
        }

        [ConfigurationProperty("showDescription")]
        private PropertyElement m_showDescription
        {
            get
            {
                PropertyElement showDescription = (PropertyElement)base["showDescription"];
                return showDescription;
            }

            set
            {
                base["showDescription"] = value;
            }
        }

        [ConfigurationProperty("indexTemplate")]
        private PropertyElement m_indexTemplate
        {
            get
            {
                PropertyElement indexTemplate = (PropertyElement)base["indexTemplate"];
                return indexTemplate;
            }

            set
            {
                base["indexTemplate"] = value;
            }
        }

        [ConfigurationProperty("createDetails")]
        private PropertyElement m_createDetails
        {
            get
            {
                PropertyElement createDetails = (PropertyElement)base["createDetails"];
                return createDetails;
            }

            set
            {
                base["createDetails"] = value;
            }
        }

        [ConfigurationProperty("detailsTemplate")]
        private PropertyElement m_detailsTemplate
        {
            get
            {
                PropertyElement detailsTemplate = (PropertyElement)base["detailsTemplate"];
                return detailsTemplate;
            }

            set
            {
                base["detailsTemplate"] = value;
            }
        }

        /*
                [ConfigurationProperty("fontName")]
                private PropertyElement m_fontName
                {
                    get
                    {
                        PropertyElement fontName = (PropertyElement)base["fontName"];
                        return fontName;
                    }

                    set
                    {
                        base["fontName"] = value;
                    }
                }

                [ConfigurationProperty("fontSize")]
                private PropertyElement m_fontSize
                {
                    get
                    {
                        PropertyElement fontSize = (PropertyElement)base["fontSize"];
                        return fontSize;
                    }

                    set
                    {
                        base["fontSize"] = value;
                    }
                }

                [ConfigurationProperty("fontColor")]
                private PropertyElement m_fontColor
                {
                    get
                    {
                        PropertyElement fontColor = (PropertyElement)base["fontColor"];
                        return fontColor;
                    }

                    set
                    {
                        base["fontColor"] = value;
                    }
                }

                [ConfigurationProperty("showThumb")]
                private PropertyElement m_showThumb
                {
                    get
                    {
                        PropertyElement showThumb = (PropertyElement)base["showThumb"];
                        return showThumb;
                    }

                    set
                    {
                        base["showThumb"] = value;
                    }
                }
        */

        public int Movies
        {
            get
            {
                return m_movies.ValueAsInt;
            }
            set
            {
                SetProperty("movies", value.ToString());
            }
        }

        public int ListType
        {
            get
            {
                return m_listType.ValueAsInt;
            }
            set
            {
                SetProperty("listType", value.ToString());
            }
        }

        public int ItemsPerPage
        {
            get
            {
                return m_itemsPerPage.ValueAsInt;
            }
            set
            {
                SetProperty("itemsPerPage", value.ToString());
            }
        }

        public string Folder
        {
            get
            {
                return m_folder.Value;
            }
            set
            {
                SetProperty("folder", value);
            }
        }

        public string IndexFileName
        {
            get
            {
                return m_indexFileName.Value;
            }
            set
            {
                SetProperty("indexFileName", value);
            }
        }

        public bool OverwriteFiles
        {
            get
            {
                return m_overwriteFiles.ValueAsBoolean;
            }
            set
            {
                SetProperty("overwriteFiles", value.ToString().ToLower());
            }
        }

        public bool OpenIndexPage
        {
            get
            {
                return m_openIndexPage.ValueAsBoolean;
            }
            set
            {
                SetProperty("openIndexPage", value.ToString().ToLower());
            }
        }

        public string IndexTtitle
        {
            get
            {
                return m_indexTitle.Value;
            }
            set
            {
                SetProperty("indexTitle", value);
            }
        }

        public int IndexType
        {
            get
            {
                return m_indexType.ValueAsInt;
            }
            set
            {
                SetProperty("indexType", value.ToString());
            }
        }

        public string FontName
        {
            get
            {
                return m_fontName.Value;
            }
            set
            {
                SetProperty("fontName", value);
            }
        }

        public decimal FontSize
        {
            get
            {
                return m_fontSize.ValueAsLong;
            }
            set
            {
                SetProperty("fontSize", value.ToString());
            }
        }

        public string FontColor
        {
            get
            {
                return m_fontColor.Value;
            }
            set
            {
                SetProperty("fontColor", value);
            }
        }

        public string BackColor
        {
            get
            {
                return m_backColor.Value;
            }
            set
            {
                SetProperty("backColor", value);
            }
        }

        public decimal ThumbSize
        {
            get
            {
                return m_thumbSize.ValueAsLong;
            }
            set
            {
                SetProperty("thumbSize", value.ToString());
            }
        }

        public bool IncludeCreationDate
        {
            get
            {
                return m_includeCreationDate.ValueAsBoolean;
            }
            set
            {
                SetProperty("includeCreationDate", value.ToString().ToLower());
            }
        }

        public int CustomLayoutType
        {
            get
            {
                return m_customLayoutType.ValueAsInt;
            }
            set
            {
                SetProperty("customLayoutType", value.ToString());
            }
        }

        public bool ShadingEnabled
        {
            get
            {
                return m_shadingEnabled.ValueAsBoolean;
            }
            set
            {
                SetProperty("shadingEnabled", value.ToString().ToLower());
            }
        }

        public bool ShowThumb
        {
            get
            {
                return m_showThumb.ValueAsBoolean;
            }
            set
            {
                SetProperty("showThumb", value.ToString().ToLower());
            }
        }

        public ArrayList Fields
        {
            get
            {
                ArrayList fields = new ArrayList();
                foreach (string name in m_fields.Value.Split(';'))
                {
                    Field field = MPMovieCatalog.Util.Fields.FindFieldByName(name);
                    if (field != null)
                    {
                        fields.Add(field);
                    }
                }

                return fields;
            }
            set
            {
                StringBuilder sb = new StringBuilder();
                foreach (Field field in value)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(";");
                    }
                    sb.Append(field.Name);
                }
                SetProperty("fields", sb.ToString());
            }
        }

        public decimal ColumnsCount
        {
            get
            {
                return m_columnsCount.ValueAsInt;
            }
            set
            {
                SetProperty("columnsCount", value.ToString());
            }
        }

        public string ThumbBackColor
        {
            get
            {
                return m_thumbBackColor.Value;
            }
            set
            {
                SetProperty("thumbBackColor", value);
            }
        }

        public bool ShowDescription
        {
            get
            {
                return m_showDescription.ValueAsBoolean;
            }
            set
            {
                SetProperty("showDescription", value.ToString().ToLower());
            }
        }

        public string IndexTemplate
        {
            get
            {
                return m_indexTemplate.Value;
            }
            set
            {
                SetProperty("indexTemplate", value);
            }
        }

        public bool CreateDetails
        {
            get
            {
                return m_createDetails.ValueAsBoolean;
            }
            set
            {
                SetProperty("createDetails", value.ToString().ToLower());
            }
        }

        public string DetailsTemplate
        {
            get
            {
                return m_detailsTemplate.Value;
            }
            set
            {
                SetProperty("detailsTemplate", value);
            }
        }
    }
}
